import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

const initState = { viewHeight: 0 }

export const usePageStore = defineStore(
  'page',
  () => {
    // const userInfo = ref<IUserInfo>({ ...initState })
    // const userToken = computed(() => {
    //   const token = uni.getStorageSync('token')
    //   return token
    // })

    const pageState = ref<IPageInfo>({ ...initState })

    const pageInfo = computed(() => {
      return pageState.value
    })

    const setPageInfo = (val: IPageInfo) => {
      pageState.value = val
    }

    const reset = () => {
      pageState.value = { ...initState }
    }

    return {
      pageInfo,
      setPageInfo,
      reset,
    }
  },
  {
    persist: true,
  },
)
